<?php

namespace App\Http\Middleware;

use Closure;

class HorizonBasicAuth
{
    /**
     * 队列监控验证
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($request->getUser() != 'admin' || md5($request->getPassword()) != '26FE3957607F8781F23C9C43228E9E51') {
            $headers = array('WWW-Authenticate' => 'Basic');
            return response('Unauthorized', 401, $headers);
        }
        return $next($request);
    }
}
